<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>定位</title>
  <style>
    *{
      margin: 0;
      padding: 0;
      list-style: none;
    }
    div{
      position: relative;
      width: 500px;
      height: 500px;
      margin: 200px auto;
      border: 1px solid #876234;
      overflow-y: scroll;
    }
    div>p{
      width: 200px;
      height: 100px;
      border: 1px solid gray;
    }
    p:nth-child(1){
      position: relative;
      /* top: 20px; */
      left: 100px;
    }
    p:nth-child(2){
      position: absolute;
      bottom: 20px;
      left: 100px;
    }
    p:nth-child(3){
      position: fixed;
      top: 120px;
      right: 100px;
    }
    p:nth-child(4){
      position: center;
      /* top: 120px; */
      /* right: 100px; */
    }
    p:nth-child(6){
      position: sticky;
      top: 0px;
      height: 1000px;
      background-color: #f5f5f5;
      opacity: .5;
    }

    .zIndexBox{
      width: 200px;
      height: 200px;
      border: 1px solid red;
      z-index: -100;
    }
    .zIndexBox>span{
      position: absolute;
      display: block;
      width: 80px;
      height: 100%;
      border: 1px solid gray;
      margin-bottom: 10px;
    }
    .zIndexBox>span:nth-child(1){
      z-index: 0;
      background-color: red;
    }
    .zIndexBox>span:nth-child(2){
      z-index: 1;
      background-color: yellow;
    }
    .zIndexBox>span:nth-child(3){
      z-index: -1;
      background-color: blue;
    }

    .fontSize{
      font-size: 32px;
    }
    .fontSize>span:nth-child(1){
      font-size: 200%;
    }
    .fontSize>span:nth-child(2){
      font-size: 50%;
    }
  </style>
</head>
<body>
  <div>
    <p>relative</p>
    <p>absolute,偏移参考最近祖先元素，祖先元素无定位元素，则回溯至body元素</p>
    <p>fixed:参考窗口</p>
    <p>center：参考祖先元素</p>
    <p>page</p>
    <p>sticky: 距离父元素位置至指定位置时，触发“fixed”</p>
    <p>placeholder</p>
    <p>placeholder</p>
    <p>placeholder</p>
    <p>placeholder</p>
    <p>placeholder</p>
    <p>placeholder</p>
    <p>placeholder</p>
    <p>placeholder</p>
    <p>placeholder</p>
    <p>placeholder</p>
    <p>placeholder</p>
    <p>placeholder</p>
    <p>placeholder</p>
    <p>placeholder</p>
  </div>
  <div class="zIndexBox">
    <span>zIndex: 0</span>
    <span>zIndex: 1</span>
    <span>zIndex: -1</span>
  </div>
  <div class="fontSize">
    根元素文字
    <span>
      子元素文字200%
    </span>
    <span>
      子元素文字50%
    </span>
  </div>
</body>
</html>